package com.lyl.config;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.beans.PropertyVetoException;

/**
 * Created by luoyiliang on 2017/7/13.
 */
@Configuration
// spring的上下文环境
public class RootConfig
{
	@Bean
	public DataSource dataSource() throws PropertyVetoException
		{
			ComboPooledDataSource dataSource=new ComboPooledDataSource();
			dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test?"
					+ "characterEncoding=utf8");
			dataSource.setUser("root");
			dataSource.setPassword("123456");
			dataSource.setDriverClass("com.mysql.jdbc.Driver");
			return dataSource;
		}
}
